package com.itheima.loop;

import java.util.Scanner;

public class sum {
    public static void main(String[] args) {
        System.out.println("请输入1到n的求和个数n：");
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        System.out.println(sum(n));
    }
    public static int sum(int n) {
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += i;
        }
        return sum;
    }
}
